package com.thon.entity.user;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.annotations.Cascade;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.thon.commons.config.Global;
import com.thon.commons.utils.ImageUrl;
import com.thon.entity.system.DicData;
import com.thon.entity.util.IdEntity;;

@Entity
@Table(name = "specialist")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Specialist extends IdEntity {

	private static final long serialVersionUID = -7316266530660143583L;
	

	private String name;
	private String sex;
	private Date birthday;
	private String zgxl;
	private String jszc;
	private String xrxzzw;
	private String xcszy;
	private DicData sfzjmc;
	private String sfzjhm;
	private String gzdwqc;
	private String address;
	private String postcode;
	private String bgdh;
	private String zzdh;
	private String yddh;
	private String email;
	private String fax;
	private Integer avatar;
	private Integer qq;
	private String resume;
	private String avatarUrl;

	
	

	@Transient
	public String getAvatarUrl() {
		return ImageUrl.format(avatar);
	}

	public void setAvatarUrl(String avatarUrl){
		this.avatarUrl = avatarUrl;
	}
	public Integer getAvatar() {
		return avatar;
	}

	public void setAvatar(Integer avatar) {
		this.avatar = avatar;
	}


	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getZgxl() {
		return zgxl;
	}

	public void setZgxl(String zgxl) {
		this.zgxl = zgxl;
	}

	public String getJszc() {
		return jszc;
	}

	public void setJszc(String jszc) {
		this.jszc = jszc;
	}

	public String getXrxzzw() {
		return xrxzzw;
	}

	public void setXrxzzw(String xrxzzw) {
		this.xrxzzw = xrxzzw;
	}

	public String getXcszy() {
		return xcszy;
	}

	public void setXcszy(String xcszy) {
		this.xcszy = xcszy;
	}

	@ManyToOne(cascade = CascadeType.MERGE)
	@JoinColumn(name="sfzjmc",nullable = false)
	@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
	public DicData getSfzjmc() {
		return sfzjmc;
	}

	
	public void setSfzjmc(DicData sfzjmc) {
		this.sfzjmc = sfzjmc;
	}

	public String getSfzjhm() {
		return sfzjhm;
	}

	public void setSfzjhm(String sfzjhm) {
		this.sfzjhm = sfzjhm;
	}

	public String getGzdwqc() {
		return gzdwqc;
	}

	public void setGzdwqc(String gzdwqc) {
		this.gzdwqc = gzdwqc;
	}

	public String getPostcode() {
		return postcode;
	}

	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}

	public String getBgdh() {
		return bgdh;
	}

	public void setBgdh(String bgdh) {
		this.bgdh = bgdh;
	}

	public String getZzdh() {
		return zzdh;
	}

	public void setZzdh(String zzdh) {
		this.zzdh = zzdh;
	}

	public String getYddh() {
		return yddh;
	}

	public void setYddh(String yddh) {
		this.yddh = yddh;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public Integer getQq() {
		return qq;
	}

	public void setQq(Integer qq) {
		this.qq = qq;
	}

	public String getResume() {
		if(!StringUtils.isBlank(resume)){
			resume = StringEscapeUtils.unescapeHtml4(resume);
			resume = resume.replaceAll("src=\"../common/attachment/download/", "src=\""+Global.getConfig("img.url"));
		}
		return resume;
	}

	public void setResume(String resume) {
		this.resume = resume;
	}

	

}
